package com.gitee.wsl.common.ui.theme.tokens

import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Typography
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.ui.text.TextStyle

enum class TypographyKeyTokens {
    BodyLarge,
    BodyMedium,
    BodySmall,
    DisplayLarge,
    DisplayMedium,
    DisplaySmall,
    HeadlineLarge,
    HeadlineMedium,
    HeadlineSmall,
    LabelLarge,
    LabelMedium,
    LabelSmall,
    TitleLarge,
    TitleMedium,
    TitleSmall;
//    H1,
//    H2,
//    H3,
//    H4,
//    H5,
//    H6,
    companion object{
        val bodyLarge = BodyLarge
        val bodyMedium = BodyMedium
        val bodySmall = BodySmall
        val displayLarge = DisplayLarge
        val displayMedium = DisplayMedium
        val displaySmall = DisplaySmall
        val headlineLarge = HeadlineLarge
        val headlineMedium = HeadlineMedium
        val headlineSmall = HeadlineSmall
        val labelLarge = LabelLarge
        val labelMedium = LabelMedium
        val labelSmall = LabelSmall
        val titleLarge = TitleLarge
        val titleMedium = TitleMedium
        val titleSmall = TitleSmall
    //    val h1 = H1
    //    val h2 = H2
    //    val h3 = H3
    //    val h4 = H4
    //    val h5 = H5
    //    val h6 = H6
    }
}

fun Typography.fromToken(token: TypographyKeyTokens): TextStyle = when(token){
    TypographyKeyTokens.BodyLarge -> bodyLarge
    TypographyKeyTokens.BodyMedium -> bodyMedium
    TypographyKeyTokens.BodySmall -> bodySmall
    TypographyKeyTokens.DisplayLarge -> displayLarge
    TypographyKeyTokens.DisplayMedium -> displayMedium
    TypographyKeyTokens.DisplaySmall -> displaySmall
    TypographyKeyTokens.HeadlineLarge -> headlineLarge
    TypographyKeyTokens.HeadlineMedium -> headlineMedium
    TypographyKeyTokens.HeadlineSmall -> headlineSmall
    TypographyKeyTokens.LabelLarge -> labelLarge
    TypographyKeyTokens.LabelMedium -> labelMedium
    TypographyKeyTokens.LabelSmall -> labelSmall
    TypographyKeyTokens.TitleLarge -> titleLarge
    TypographyKeyTokens.TitleMedium -> titleMedium
    TypographyKeyTokens.TitleSmall -> titleSmall
//    TypographyKeyTokens.H1 -> h1
//    TypographyKeyTokens.H2 -> h2
//    TypographyKeyTokens.H3 -> h3
//    TypographyKeyTokens.H4 -> h4
//    TypographyKeyTokens.H5 -> h5
//    TypographyKeyTokens.H6 -> h6
}

@ReadOnlyComposable
@Composable
fun TypographyKeyTokens.toTextStyle(): TextStyle {
    return MaterialTheme.typography.fromToken(this)
}

val MaterialTheme.typographyToken get() = TypographyKeyTokens